<script src="https://login.persona.org/include.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        var persona_option = $('#persona-option');
        if (persona_option) {
            persona_option.show();
            var form = $("#social_dropdown_form");
            var submit = false;
            form.submit(function() {
                if ($('#backend-select').val() == 'persona') {

                    if (submit == true) {
                        return true;
                    }

                    navigator.id.get(function (assertion) {
                        if (assertion) {
                            $('#assertion').attr('value', assertion);
                            submit = true;
                            form.submit();
                        }  else {
                            alert('Some error occurred. Please try again...');
                        }
                    });

                    return false;
                }
            });
        }
    });
</script>